import { commonRequest } from '@/api/commonHttp';

// 库存管理 - 库存溢出管理 - 库存列表查询
export const queryStockListService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/queryList',
  type: 'post',
  data,
  loadingFn
});
// 库存管理 - 库存溢出管理 - 库存列表查询条件下拉选项
export const querySearchConditionOptionsService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/queryDropdownItemList',
  type: 'post',
  data,
  loadingFn
});
// 库存管理 - 库存溢出管理 - 导出文件
export const exportStockFileService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/exportExcel',
  type: 'post',
  data,
  loadingFn,
  isExport: true
});
// 库存管理 - 库存溢出管理 - 处理
export const dealStockService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/processCpfrStock',
  type: 'post',
  data,
  loadingFn,
});
// 库存管理 - 库存溢出管理 - 处理日志
export const dealLogService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/queryProcessLogList',
  type: 'get',
  data,
  loadingFn
});
// 库存管理 - 库存溢出管理 - 转区域、转集团、跨区域转派
export const transferGoodsService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/reassignment',
  type: 'POST',
  data,
  loadingFn
});
// 库存管理 - 库存溢出管理 - 出入库记录
export const stockRecordService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/queryStockHistory',
  type: 'post',
  data,
  loadingFn
});
// 库存管理 - 库存溢出管理 - 导出出入库记录
export const stockRecordExportService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/stockHistoryExport',
  type: 'post',
  data,
  loadingFn,
  isExport: true
});
// 库存管理 - 库存溢出管理 - 出入库记录详情
export const queryStockRecordDetailService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/getStockHistoryRecordDetail',
  type: 'post',
  data,
  loadingFn
});

// 库存管理 - 库存溢出管理 - 区域数据
export const areaDataService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/getAllCompanySaleDataOfArea',
  type: 'post',
  data,
  loadingFn
});

// 库存管理 - 库存溢出管理 - 添加产生原因
export const setCauseReasonsService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/setCauseReason',
  type: 'post',
  data,
  loadingFn
});

// 库存管理 - 库存溢出管理 - 复核
export const reviewService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/reView',
  type: 'post',
  data,
  loadingFn
});

// 库存管理 - 库存溢出管理 - 查看供应商
export const querySpplierListService = (data, loadingFn) => commonRequest({
  url: `/sysback/cpfrStockManager/getAllSupplyInfo?id=${data.id || ''}`,
  type: 'post',
  data,
  loadingFn
});
// 库存管理 - 库存溢出管理 - 备注列表 1 处理方式 2 产生原因
export const queryRemarkListService = (data, loadingFn) => commonRequest({
  url: `/sysback/cpfrStockManager/getRemarkList?type=${data.type || ''}`,
  type: 'post',
  data,
  loadingFn
});
// 库存管理 - 库存溢出管理 - 备注设置
export const setRemarkService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/modifyRemark',
  type: 'post',
  data,
  loadingFn
});

// 库存管理 - 库存溢出管理 - 提交 留存销售、打折退厂、内部促销
export const submitStockService = (data, loadingFn) => commonRequest({
  url: ' /sysback/cpfrStockManager/commitOthersToOa',
  type: 'post',
  data,
  loadingFn
});

/**
 * 跨区域转货
 */
// 跨区域转货 - 获取跨区域转货申请单列表数据
export const queryTransferDataService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/toCommitAreaTransferRecord',
  type: 'post',
  data,
  loadingFn
});
// 跨区域转货 - 获取跨区域转货详情
export const queryTransferDetailService = (data, loadingFn) => commonRequest({
  url: `/sysback/cpfrStockManager/queryAreaTransferRecordDetail?recordNo=${data.recordNo}`,
  type: 'post',
  data,
  loadingFn
});
// 跨区域转货 - 查看页面导出
export const transferGoodsExportService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/exportAreaTransferRecordDetail',
  type: 'get',
  data,
  loadingFn,
  isExport: true
});
// 跨区域转货 - 自动获取转货公司
export const selectTransferCompanyService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/autoSelectReceiveCompanyList',
  type: 'post',
  data,
  loadingFn
});
// 跨区域转货 - 获取收货公司
export const queryTransferCompanyService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/queryReceiveCompanyList',
  type: 'post',
  data,
  loadingFn
});
// 跨区域转货 - 提交
export const submitTransferDataService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/commitAreaTransferRecordToOa',
  type: 'post',
  data,
  loadingFn
});

// 跨区域转货 - 计算消化天数
export const computeDigestionDaysService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/calculateDigestionDays',
  type: 'post',
  data,
  loadingFn
});
// 跨区域转货 - 校验是否超上线
export const validIsExceedUpperLimitService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/validIsExceedUpperLimit',
  type: 'post',
  data,
  loadingFn
});

// 处理 - 校验是否有处理权限
export const validProcessAuthService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/validProcessAuth',
  type: 'post',
  data,
  loadingFn
});

// 库存管理 - 库存溢出管理 - 导入批量维护
export const queryUploadStockListService = (data, loadingFn) => commonRequest({
  url: '/dataBatch/purchasePrice/page',
  type: 'post',
  data,
  loadingFn
});

// 库存管理 - 库存溢出管理 - 下载正常or异常数据
export const queryDownloadUrlService = (data, loadingFn) => commonRequest({
  url: `/dataBatch/purchasePrice/file/downloadUrl/${data.type}/${data.batchNo}`,
  type: 'get',
  data: {},
  loadingFn
});

// 存量溢出 - 重置处理部门
export const resetProcessDeptService = (data, loadingFn) => commonRequest({
  url: '/sysback/cpfrStockManager/resetProcessDept',
  type: 'post',
  data,
  loadingFn
});
